var t = require("../../../../@babel/runtime/helpers/toConsumableArray"), a = getApp(), e = require("../../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ e ],
    data: {
        statusValue: 0,
        selectShow: !1,
        selectType: 0,
        record_list: [],
        money_arr: [],
        currentDate: new Date().getTime(),
        maxDate: new Date().getTime(),
        show: !1,
        postDate: "",
        formatter: function(t, a) {
            return "year" === t ? "".concat(a, "年") : "month" === t ? "".concat(a, "月") : a;
        },
        noneShow: !0,
        selectTapInd: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.getData();
        try {
            var a = wx.getStorageSync("balance");
            a && (this.setData({
                balanceLang: a
            }), wx.setNavigationBarTitle({
                title: a + "明细"
            }));
        } catch (t) {}
        this.serviceType();
    },
    init: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            record_list: [],
            money_arr: [],
            selectShow: !1
        });
    },
    cancel: function() {
        this.setData({
            show: !1
        });
    },
    pickConfirm: function(t) {
        var a = this.timestampToTime(t.detail);
        this.setData({
            postDate: a,
            show: !1
        }), this.init(), this.getData();
    },
    timestampToTime: function(t, a) {
        if (!Number(t) || "" == t) return "";
        var e = new Date(t);
        return console.log(e, "ddddd1"), e.getFullYear() + "-" + ((e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1) + "-") + (e.getDate() < 10 ? "0" + e.getDate() : e.getDate());
    },
    selectStatus: function(t) {
        var a = t.currentTarget.dataset.key;
        this.setData({
            statusValue: a
        }), this.init(), this.getData();
    },
    selectShowTap: function() {
        this.setData({
            selectShow: !this.data.selectShow
        });
    },
    closeShow: function() {
        this.setData({
            selectShow: !1
        });
    },
    selectTap: function(t) {
        this.init();
        var a = t.currentTarget.dataset.item.id, e = t.currentTarget.dataset.ind;
        this.setData({
            selectType: a,
            selectShow: !1,
            selectTapInd: e
        }), this.getData();
    },
    showTap: function() {
        this.setData({
            show: !0
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    godetails: function(t) {
        var a = t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageA/member/balance/details/details?item=" + JSON.stringify(a)
        });
    },
    serviceType: function() {
        var t = this, e = a.getNetAddresss("finance.balance.get-service-type-list");
        a._postNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var s = e.data;
                    s.unshift({
                        id: 0,
                        name: "业务类型"
                    }), t.setData({
                        serviceTypeList: s
                    }), console.log(s);
                } else t.setData({
                    noneShow: !0,
                    isLoadMore: !1,
                    record_list: []
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, e = {
            search: {
                record_type: this.data.statusValue,
                date: this.data.postDate,
                service_type: this.data.selectType
            }
        };
        this.data.page = 1;
        var s = a.getNetAddresss("finance.balance.record");
        a._postNetWork({
            url: s,
            data: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.setData({
                    total_page: e.data.record_list.last_page,
                    money_arr: e.data.money_arr,
                    record_list: e.data.record_list,
                    noneShow: !1
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                })) : t.setData({
                    noneShow: !0,
                    isLoadMore: !1,
                    record_list: []
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var s = {
                search: {
                    record_type: this.data.statusValue,
                    date: this.data.postDate,
                    service_type: this.data.selectType
                },
                page: this.data.page
            }, o = a.getNetAddresss("finance.balance.record");
            a._postNetWork({
                url: o,
                data: s,
                success: function(a) {
                    var s = a.data;
                    if (1 == s.result) {
                        var o = s.data.record_list.data;
                        for (var i in o) e.data.record_list.data[i] ? e.data.record_list.data[i] = [].concat(t(e.data.record_list.data[i]), t(o[i])) : e.data.record_list.data[i] = o[i];
                        e.setData({
                            record_list: e.data.record_list,
                            money_arr: Object.assign(e.data.money_arr, s.data.money_arr)
                        }), e.isLoadMore = !0;
                    } else e.setData({
                        page: e.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    swichTabTItem: function(t) {
        var a = t.detail.index;
        this.setData({
            selected: a,
            recordsList: []
        }), this.getNetData(this.data.selected);
    }
});